import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'
import userManage from '../components/manage/userManage.vue'
import articleManage from '../components/manage/articleManage.vue'
import articleCateManage from '../components/manage/articleCateManage.vue'
import homecontent from '../views/content/homeContent/HomeContent.vue'
import changedData from '../views/content/homeContent/changedData.vue'
import articleClassify from '@views/content/articleClassify/articleClassify.vue'
import resume from '@views/content/resume/resume.vue'
Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push
// 修改 原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err=>err)
}
const routes = [
  { //主页面
    path: '',
    name: 'blogHome',
    // route level code-splitting
    // this generates a separate chunk (home.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "home" */ '../views/BlogView.vue'),
    children: [
      { //首页
        path: '',
        name:'homecontent',
        component:homecontent,
      },
      { //分类
        path:'',
        name:'articleClassify',
        component:articleClassify
      },
      {//个人简历
        path:'',
        name:'resume',
        component:resume
      }
      
    ]
  },
  { //注册
    path: '/login',
    name: 'login',
    component: Login
  },
  { //管理页面
    path: '/page',
    name: 'page',
    // route level code-splitting
    // this generates a separate chunk (home.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "home" */ '../views/manage/manage.vue'),
    children: [
      {
        path: '/userManage',
        name:'userManage',
        component:userManage,
      },
      {
        path: '/articleManage',
        name:'articleManage',
        component:articleManage,
      },
      {
        path: '/articleCateManage',
        name:'articleCateManage',
        component:articleCateManage,
      },
      
    ]
  },
  {//修改个人资料
    path: '/changedData',
    name: 'changedData',
    component:changedData
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
